<!DOCTYPE html>
<html lang="en">
{include file="common/header" /}

<body>
<!--swiper start-->
{include file="common/banner" /}
<!--swiper end-->
<!--zhibo start-->
<div class="zhibo">
    <a href="{:$analysis['jxurl']}" target="_blank"><img src="{:$analysis['image']}" /></a>
</div>
<!--zhibo end-->
<!--list start-->
<ul class="skill-list" data-cate="{:$cate}">

    {volist name="categorys" id="vo"}

    {if condition="($vo['myview']=='yes')"}
    <li class="myview current" data-tip="{:$vo['myview']}" data-id="{:$vo['id']}" data-url="{:url('index/article/index',['id'=>$vo.id])}">
        {else /}
    <li class="myview" data-id="{:$vo['id']}" data-tip="{:$vo['myview']}" data-url="{:url('index/article/index',['id'=>$vo.id])}">
        {/if}

        <a href="javascript:void(0);">
            {:$vo['name']}
        </a>
        <span class="right-arrow">
            {:$vo['viewstatus']}
        </span>
    </li>
    {/volist}
</ul>
<!--list end-->
<!--code start-->
<div class="code-box">
    <div class="code-content">
        <img src="{$qrcode['image']}" />
        <p>扫描回复<span class="red" style="font-weight: bold;font-size: 18px;">{$qrcode['name']}</span></p>
        <p>免费查看</p>
        <img src="/assets/img/closed.png" class="closed" />
    </div>
</div>
<!--code end-->
<script src="/assets/js/jquery.min.js"></script>
<script src="/assets/js/swiper.min.js"></script>
<script type="text/javascript">
    //localStorage.removeItem('old_wechat_open_id_new');
    //localStorage.removeItem('old_wechat_token');
</script>
<script type="text/javascript">

function textTip(str, t, callBack) {
		    t = t || 2000;
		    var dom = document.createElement("p");
		    dom.setAttribute('class', 'text-tip');
		    document.body.appendChild(dom);
		    var mytip = document.querySelector('.text-tip')
		    
		    mytip.style.display="block";
		    mytip.innerHTML = str;
		    var tipHeight = mytip.offsetHeight;
		    
		    //文字两行或两行以上
		    if((tipHeight - 20)/18>1){
		    	mytip.style.width = "55%";
		    }
		    setTimeout(function () {
		        mytip.style.display="none";
		        mytip.parentNode.removeChild(mytip);
		        if (callBack) {callBack();}
		    }, t);
		}
    function empty(obj) {
        if (obj=='undefined') {
            return true;
        }
        if (obj === null) return true;
        if (typeof obj === 'undefined') {
            return true;
        }
        if (typeof obj === 'string') {
            if (obj === "") {
                return true;
            }
            var reg = new RegExp("^([ ]+)|([　]+)$");
            return reg.test(obj);
        }
        if(obj==0){
            return true;
        }

        return false;
    }
    var host = window.location.protocol+"//"+window.location.host+'/'+'index/index/index';
    var redirect_url = encodeURIComponent(host);
    function getQueryString(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if (r != null) return unescape(r[2]);
        return null;
    }

    if (String(getQueryString('code')) == 'null'&&empty(localStorage.getItem('old_wechat_open_id_new'))) {
        window.location.href = '/index/index/getbase?redirect_url='+redirect_url;
    }



    //来源
    if(String(getQueryString('source')) == 'article'){
        $('.code-box').show(function () {
            $('body').on('click','.closed',function () {
                $('.code-box').hide();
            })
        })
    }



    var bt_open_id = localStorage.getItem('old_wechat_open_id_new')

    if (empty(bt_open_id) || bt_open_id =='undefined') {
        $.ajax({
            url: '/index/index/getopenid',
            type: "post",
            async: false,
            data: {
                code: getQueryString('code')
            },
            success: function(e) {
                e = JSON.parse(e)
                localStorage.setItem('old_wechat_open_id_new', e.data.openid)
                localStorage.setItem('old_wechat_token', e.data.token)
                isFollow(e.data.openid)
            }
        })
    }


    function isFollow(open_id) {
        //是否关注公众号
        $.ajax({
            url: '/index/index/isflow',
            type: "post",
            async: false,
            data: {
                openid: open_id,
                cate:"{:$cate}"
            },
            success: function(e) {

                e = JSON.parse(e);
                // alert(e.data.isFollow)
                if (e.data.isFollow == 0) {
                    $('.code-box').show(function () {
                        $('body').on('click','.closed',function () {
                            $('.code-box').hide();
                        })
                    })
                    localStorage.removeItem('fenxiang');
                } else {
                    is_share_flg = 1;
                }
            }
        })
    }


    var global_is_follow = 0;

    $('body').on('click','.myview',function () {
        var tzurl = $(this).attr('data-url');
        var datatip = $(this).attr('data-tip');
        //是否关注公众号
        $.ajax({
            url: '/index/index/isflow',
            type: "post",
            data: {
                openid: localStorage.getItem('old_wechat_open_id_new'),
                cate:"{:$cate}"
            },
            success: function(e) {
                e = JSON.parse(e);
                //alert(e.data.isFollow)
                if (e.data.isFollow == 0 ||empty(e.data.isFollow)) {
                    global_is_follow = 0;
                    $('.code-box').show(function () {
                        $('body').on('click','.closed',function () {
                            $('.code-box').hide();
                        })
                    });
                    localStorage.removeItem('fenxiang');
                } else {
                    //去查看网页内容
                    global_is_follow = 1;
                  	
                    if(datatip=='yes'){
                        location.href = tzurl;
                    }else{
                        //alert('敬请期待！');
                        	textTip('敬请期待！', 2000, function () {
						});

                    }

                    return false;
                }


            },
            error: function(){

            }
        });
        if (global_is_follow==0) {
            localStorage.removeItem('fenxiang');
            return;
        }

    })



</script>

<script type="text/javascript" src='http://res.wx.qq.com/open/js/jweixin-1.2.0.js'></script>
<script type="text/javascript">
    $(function () {
        wx.config({
            debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
            appId: "{:$signpackage['appId']}", // 必填，公众号的唯一标识
            timestamp: "{:$signpackage['timestamp']}", // 必填，生成签名的时间戳
            nonceStr: "{:$signpackage['nonceStr']}", // 必填，生成签名的随机串
            signature: "{:$signpackage['signature']}",// 必填，签名
            jsApiList: [
                'onMenuShareTimeline',
                'onMenuShareAppMessage',
            ]
        });


        wx.ready(function () {
            var shareData = {
                //标题
                title: "{:$myshare['name']}",
                //摘要
                desc: "{:$myshare['description']}",
                //链接,可以换主页
                link:"{:$myshare['link']}" ,
                //缩略图
                imgUrl: "{:$myshare['image']}",
                success: function() {
                    $.ajax({
                        url:'/index/article/mark',
                        type:'post',
                        data:{openid:localStorage.getItem('old_wechat_open_id_new'),token:localStorage.getItem('old_wechat_token'),url:'/index/index/index',cate:$('#myshare').attr('data-cate'),share_type:1},
                        success:function (e) {
                            $('#myshare').css('display','none');
                            localStorage.setItem('fenxiang', 'yes');
                            //location.href = url;
                        }
                    });

                },
                fail:function(res){
                    alert('fail');
                },
                cancel: function() {
                    alert('分享失败');
                    //localStorage.removeItem('fenxiang');
                    console.log('分享失败1');
                    $('#myshare').css('display','block');
                }
            };

            wx.onMenuShareTimeline(shareData);
            wx.onMenuShareAppMessage(shareData);


        });
    })
</script>


</body>
</html>